import style from './index.module.scss'
import { NavBar } from 'antd-mobile'
import { headerType } from '@/type'
import { useNavigate } from 'react-router-dom'

const HeaderView = (props: headerType) => {
  const navigate = useNavigate()
  const back = () => {
    if(window.location.pathname === '/address') {
      navigate('/mine') 
    } else {
      navigate(-1)
    }
  }

  return(
    <div className={style.header}>
      <NavBar back={props.backIcon && '返回'} onBack={back} backIcon={props.backIcon}>{props.title}</NavBar>
    </div>
  )
}

export default HeaderView